package com.zhuiyun.project.api.timepool.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuiyun.project.api.timepool.entity.TimePool;
import com.zhuiyun.project.api.timepool.mapper.TimePoolMapper;
import com.zhuiyun.project.api.timepool.service.TimePoolService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @ClassName TimePoolServiceImpl
 * @Description TODO
 * @Author wuwan
 * @Date 2023/12/18 10:58
 **/
@Service
public class TimePoolServiceImpl extends ServiceImpl<TimePoolMapper, TimePool> implements TimePoolService {

    @Autowired
    TimePoolMapper timePoolMapper;
    @Resource
    TimePoolService timePoolService;


    @Override
    public boolean SaveUpdateTimePool(TimePool timePool, String  startTime, String  endTime) {
        // 判断id是否为空，为空则为新增，不为空则为修改
        if (timePool.getId() == null) {
            // 设置时间安排
            timePool.setArrangeTime(startTime + "-" + endTime);
            return timePoolService.save(timePool);
        }else{
            timePool.setArrangeTime(startTime + "-" + endTime);
            return timePoolService.updateById(timePool);
        }

    }
}
